package com.glsc.ngateway.common.base.repo.mysql.gateway.platform.it;

import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItDomain;
import feign.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ItDomainRepo extends JpaRepository<ItDomain, Integer> {

    @Query("select a from ItDomain a where isDelete = 0" +
            "and ((:key is null or domain like CONCAT('%',:key,'%')) " +
            "or (:key is null or serviceProvider like  CONCAT('%',:key,'%')) " +
            "or (:key is null or administratorName like  CONCAT('%',:key,'%')) " +
            "or (:key is null or useTo like CONCAT('%',:key,'%')) " +
            "or (:key is null or state like CONCAT('%',:key,'%')) " +
            "or (:key is null or ICPstate like  CONCAT('%',:key,'%'))) ")
    Page<ItDomain> searchByKey(Pageable pageable, String key);

    List<ItDomain> findAllByIsDelete(@Param("isDelete") Integer IsDelete);
}
